package tool;

import aboutbook.Book;
import aboutbook.BookList;

import java.util.Scanner;

public class Find implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("查找方法");
        System.out.println("请输入你想要查找的书名");
        Scanner myScanner = new Scanner(System.in);
        String bookName = myScanner.nextLine();

        int currentnum = bookList.getBebooks();

        for (int i = 0; i < currentnum; i++) {
            Book book = bookList.getbooks(i);

            if(book.getName().equals(bookName)){
                System.out.println("找到了这边书");
                System.out.println(book.toString());
                return;
            }
        }
        System.out.println("没有这本书");
    }

}
